package bosque.unc.simulador;

import java.awt.EventQueue;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import java.awt.Dimension;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import java.awt.Color;
import javax.swing.UIManager;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JTable;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.border.LineBorder;
import javax.swing.JTextArea;
import java.awt.SystemColor;
import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JCheckBox;

import bosque.unc.Funciones;
import bosque.unc.enumerations.Angulo;
import bosque.unc.enumerations.EncoderNombre;
import bosque.unc.enumerations.Mensajes;
import bosque.unc.enumerations.Notificacion;
import bosque.unc.exceptions.CaladoException;
import bosque.unc.gui.Scoba;

public class Simulador extends JFrame implements Observer
{

	private static Scoba scoba;
	private Automatico autoCupula;
	private Automatico autoEncoder;
	private Automatico autoPlataf;

	
	
	//private JFrame frmSicbaV;
	private JPanel panelImagen;
	private Image img;
	private ImageIcon imageicon;
	private JTextArea textAlfaSeg;
	private Updater updater;
	private EncoderSimulator encoderAlfa;
	private EncoderSimulator encoderDelta;
	private Boolean autoMode = false;
	private JEditorPane paneVelLenta;
	private JEditorPane paneCupIzq;
	private JEditorPane paneCupDer;
	private JEditorPane panePlatAf;
	private JEditorPane panePlatAd;
	private JEditorPane panePlatAb;
	private JEditorPane panePlatArr;
	private JEditorPane paneTablero;
	private JEditorPane panePulsador;
	private JEditorPane paneReloj;
	private JEditorPane paneConsRampa;
	private JEditorPane paneSecAleja;
	private JEditorPane paneSecAcerca;
	private JEditorPane paneVelTel;
	private JEditorPane paneTelDeclin;
	private JEditorPane paneTelNor;
	private JEditorPane paneTelSur;
	private JEditorPane paneTelEste;
	private JEditorPane paneTelRE;
	private JEditorPane paneTelOeste;
	private JEditorPane paneTelRO;
	private JEditorPane paneTelGuiado;
	private JEditorPane paneTelCalado;
	private JEditorPane paneEspecEntFiltro;
	private JEditorPane paneEspecFiltro2;
	private JEditorPane paneEspecFiltro1;
	private JEditorPane paneEspecRedmenos;
	private JEditorPane paneEspecRedmas;
	private JEditorPane paneEspecLed;
	private JEditorPane paneEspecCompar;
	private JEditorPane paneEspecContinuo;
	private JEditorPane paneEspecObtur;
	private JEditorPane paneEspecRanura;
	private JEditorPane paneEspecEjeXmenos;
	private JEditorPane paneEspecEjeXmas;
	private JEditorPane paneEspecEjeYmenos;
	private JEditorPane paneEspecEjeYmas;
	private JEditorPane paneEspecMov;
	private JTextArea textAlfaMin;
	private JTextArea textAlfaGrad;
	private JTextArea textAlfaSign;
	private JTextArea textDeltaSeg;
	private JTextArea textDeltaMin;
	private JTextArea textDeltaGrad;
	private JTextArea textDeltaSign;
	private JTextField textFunc;
	//private Config frameConfig;
	private JTextField textFines;
	private JTextField text2lsb;
	private JTextField textTempExt;
	private JTextField textTempEspejo;
	private JTextField textPlatARAB;
	
	private JTextField textPlatADAF;
	private JTextField textCupula;
	private JTextField textEspecX;
	private JTextField textEspecY;
	private JTextField textEspecRed;
	private JTextField textCupula10b;
	private JTextField textEspecX10b;
	private JTextField textEspecY10b;
	private JTextField textEspecRed10b;
	private JTextField textFieldVelTel;
	//private Auto auto;
	private JEditorPane paneInterfaz0;
	private JEditorPane paneInterfaz1;
	private JEditorPane paneHabNS;
	private JEditorPane paneHabEO;
	private JButton btnConnect;
	private JCheckBox chckbxAutoMode;
	private Font fuente7Seg;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Simulador frame = new Simulador(scoba);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}


	/**
	 * Create the application.
	 */
	public Simulador(Scoba s)
	{
		setResizable(false);
		this.scoba = s;
		this.updater = new Updater(this);
		this.encoderAlfa = new EncoderSimulator(EncoderNombre.ALFA);
		this.encoderDelta = new EncoderSimulator(EncoderNombre.DELTA);
		encoderAlfa.addObserver(this);
		encoderDelta.addObserver(this);
		//this.encoderAlfa.setSegundos(50);
		//this.auto = new Auto(this, EncoderNombre.ALFA);
		initialize();
		//updater.start();
		//auto.start();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize()
	{
		// Cargar manualmente la fuente de 7 segmentos
		InputStream istream = getClass().getResourceAsStream("resources/font_7s.ttf");
		
		try {
			fuente7Seg = Font.createFont(Font.TRUETYPE_FONT, istream);
		} catch (FontFormatException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		fuente7Seg = fuente7Seg.deriveFont(54.0f);
		fuente7Seg = fuente7Seg.deriveFont(Font.BOLD);
		
		
		//this.img = new ImageIcon("img/frente3.jpg").getImage();
		
		//frmSicbaV = new JFrame();
		setTitle("Simulador de la Interfaz de Control de Bosque Alegre");
		setBounds(100, 100, 806, 693);
		//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		getContentPane().setLayout(null);
		
		panelImagen = new JPanel();
		panelImagen.setBorder(new LineBorder(new Color(0, 0, 0), 3, true));
		panelImagen.setBounds(10, 11, 356, 622);
//		Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
//		    this.panelImagen.setPreferredSize(size);
//		    this.panelImagen.setMinimumSize(size);
//		    this.panelImagen.setMaximumSize(size);
//		    this.panelImagen.setSize(size);
		getContentPane().add(panelImagen);
		panelImagen.setLayout(null);
		
		JPanel panelConsola = new JPanel();
		panelConsola.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Consola", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 128)));
		panelConsola.setBounds(22, 48, 134, 143);
		panelImagen.add(panelConsola);
		panelConsola.setLayout(null);
		
		JLabel lblTablero = new JLabel("Tablero");
		lblTablero.setHorizontalAlignment(SwingConstants.RIGHT);
		lblTablero.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblTablero.setBounds(10, 24, 57, 14);
		panelConsola.add(lblTablero);
		
		paneTablero = new JEditorPane();
		paneTablero.setEditable(false);
		paneTablero.setBounds(93, 25, 27, 10);
		panelConsola.add(paneTablero);
		
		JLabel labelPulsador = new JLabel("Pulsador");
		labelPulsador.setHorizontalAlignment(SwingConstants.RIGHT);
		labelPulsador.setFont(new Font("Tahoma", Font.BOLD, 11));
		labelPulsador.setBounds(10, 43, 57, 14);
		panelConsola.add(labelPulsador);
		
		panePulsador = new JEditorPane();
		panePulsador.setEditable(false);
		panePulsador.setBounds(93, 44, 27, 10);
		panelConsola.add(panePulsador);
		
		JLabel lblRelojeria = new JLabel("Relojer\u00EDa");
		lblRelojeria.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRelojeria.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRelojeria.setBounds(10, 63, 57, 14);
		panelConsola.add(lblRelojeria);
		
		paneReloj = new JEditorPane();
		paneReloj.setEditable(false);
		paneReloj.setBounds(93, 64, 27, 10);
		panelConsola.add(paneReloj);
		
		JLabel lblConsRampa = new JLabel("Rampa");
		lblConsRampa.setHorizontalAlignment(SwingConstants.RIGHT);
		lblConsRampa.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblConsRampa.setBounds(10, 82, 57, 14);
		panelConsola.add(lblConsRampa);
		
		paneConsRampa = new JEditorPane();
		paneConsRampa.setEditable(false);
		paneConsRampa.setBounds(93, 83, 27, 10);
		panelConsola.add(paneConsRampa);
		
		JLabel lblInterfaz0 = new JLabel("Interfaz0");
		lblInterfaz0.setHorizontalAlignment(SwingConstants.RIGHT);
		lblInterfaz0.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblInterfaz0.setBounds(10, 100, 57, 14);
		panelConsola.add(lblInterfaz0);
		
		paneInterfaz0 = new JEditorPane();
		paneInterfaz0.setEditable(false);
		paneInterfaz0.setBounds(93, 101, 27, 10);
		panelConsola.add(paneInterfaz0);
		
		JLabel lblInterfaz_1 = new JLabel("Interfaz1");
		lblInterfaz_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblInterfaz_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblInterfaz_1.setBounds(10, 118, 57, 14);
		panelConsola.add(lblInterfaz_1);
		
		paneInterfaz1 = new JEditorPane();
		paneInterfaz1.setEditable(false);
		paneInterfaz1.setBounds(93, 119, 27, 10);
		panelConsola.add(paneInterfaz1);
		
		JPanel panelTelescopio = new JPanel();
		panelTelescopio.setLayout(null);
		panelTelescopio.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Telescopio", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 128)));
		panelTelescopio.setBounds(22, 202, 134, 303);
		panelImagen.add(panelTelescopio);
		
		JLabel labelAcel = new JLabel("Velocidad");
		labelAcel.setHorizontalAlignment(SwingConstants.RIGHT);
		labelAcel.setFont(new Font("Tahoma", Font.BOLD, 11));
		labelAcel.setBounds(10, 24, 57, 14);
		panelTelescopio.add(labelAcel);
		
		paneVelTel = new JEditorPane();
		paneVelTel.setEditable(false);
		paneVelTel.setBounds(93, 25, 27, 10);
		panelTelescopio.add(paneVelTel);
		
		JLabel lblDec = new JLabel("DEC");
		lblDec.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDec.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblDec.setBounds(10, 43, 57, 14);
		panelTelescopio.add(lblDec);
		
		paneTelDeclin = new JEditorPane();
		paneTelDeclin.setEditable(false);
		paneTelDeclin.setBounds(93, 44, 27, 10);
		panelTelescopio.add(paneTelDeclin);
		
		JLabel lblNorte = new JLabel("Norte");
		lblNorte.setHorizontalAlignment(SwingConstants.RIGHT);
		lblNorte.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblNorte.setBounds(10, 63, 57, 14);
		panelTelescopio.add(lblNorte);
		
		paneTelNor = new JEditorPane();
		paneTelNor.setEditable(false);
		paneTelNor.setBounds(93, 64, 27, 10);
		panelTelescopio.add(paneTelNor);
		
		JLabel lblSur = new JLabel("Sur");
		lblSur.setHorizontalAlignment(SwingConstants.RIGHT);
		lblSur.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblSur.setBounds(10, 82, 57, 14);
		panelTelescopio.add(lblSur);
		
		paneTelSur = new JEditorPane();
		paneTelSur.setEditable(false);
		paneTelSur.setBounds(93, 83, 27, 10);
		panelTelescopio.add(paneTelSur);
		
		paneTelRO = new JEditorPane();
		paneTelRO.setEditable(false);
		paneTelRO.setBounds(93, 159, 27, 10);
		panelTelescopio.add(paneTelRO);
		
		paneTelOeste = new JEditorPane();
		paneTelOeste.setEditable(false);
		paneTelOeste.setBounds(93, 140, 27, 10);
		panelTelescopio.add(paneTelOeste);
		
		paneTelRE = new JEditorPane();
		paneTelRE.setEditable(false);
		paneTelRE.setBounds(93, 120, 27, 10);
		panelTelescopio.add(paneTelRE);
		
		paneTelEste = new JEditorPane();
		paneTelEste.setEditable(false);
		paneTelEste.setBounds(93, 101, 27, 10);
		panelTelescopio.add(paneTelEste);
		
		JLabel lblEste = new JLabel("Este");
		lblEste.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEste.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEste.setBounds(10, 100, 57, 14);
		panelTelescopio.add(lblEste);
		
		JLabel lblOeste = new JLabel("RE");
		lblOeste.setHorizontalAlignment(SwingConstants.RIGHT);
		lblOeste.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblOeste.setBounds(10, 119, 57, 14);
		panelTelescopio.add(lblOeste);
		
		JLabel lblRo = new JLabel("Oeste");
		lblRo.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRo.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRo.setBounds(10, 139, 57, 14);
		panelTelescopio.add(lblRo);
		
		JLabel lblRo_1 = new JLabel("RO");
		lblRo_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRo_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRo_1.setBounds(10, 158, 57, 14);
		panelTelescopio.add(lblRo_1);
		
		JLabel lblCalado = new JLabel("Calado");
		lblCalado.setHorizontalAlignment(SwingConstants.RIGHT);
		lblCalado.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblCalado.setBounds(10, 194, 57, 14);
		panelTelescopio.add(lblCalado);
		
		JLabel lblGuiado = new JLabel("Guiado");
		lblGuiado.setHorizontalAlignment(SwingConstants.RIGHT);
		lblGuiado.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGuiado.setBounds(10, 175, 57, 14);
		panelTelescopio.add(lblGuiado);
		
		paneTelGuiado = new JEditorPane();
		paneTelGuiado.setEditable(false);
		paneTelGuiado.setBounds(93, 176, 27, 10);
		panelTelescopio.add(paneTelGuiado);
		
		paneTelCalado = new JEditorPane();
		paneTelCalado.setEditable(false);
		paneTelCalado.setBounds(93, 195, 27, 10);
		panelTelescopio.add(paneTelCalado);
		
		JLabel labelVelTel = new JLabel("Rampa:");
		labelVelTel.setHorizontalAlignment(SwingConstants.RIGHT);
		labelVelTel.setFont(new Font("Tahoma", Font.BOLD, 11));
		labelVelTel.setBounds(10, 278, 57, 14);
		panelTelescopio.add(labelVelTel);
		
		textFieldVelTel = new JTextField();
		textFieldVelTel.setFont(new Font("Tahoma", Font.PLAIN, 11));
		textFieldVelTel.setEditable(false);
		textFieldVelTel.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldVelTel.setText("00");
		textFieldVelTel.setBounds(93, 275, 27, 17);
		panelTelescopio.add(textFieldVelTel);
		textFieldVelTel.setColumns(10);
		
		JLabel labelHabNS = new JLabel("Hab N/S");
		labelHabNS.setHorizontalAlignment(SwingConstants.RIGHT);
		labelHabNS.setFont(new Font("Tahoma", Font.BOLD, 11));
		labelHabNS.setBounds(10, 219, 57, 14);
		panelTelescopio.add(labelHabNS);
		
		paneHabNS = new JEditorPane();
		paneHabNS.setEditable(false);
		paneHabNS.setBounds(93, 220, 27, 10);
		panelTelescopio.add(paneHabNS);
		
		JLabel labelHabEO = new JLabel("Hab E/O");
		labelHabEO.setHorizontalAlignment(SwingConstants.RIGHT);
		labelHabEO.setFont(new Font("Tahoma", Font.BOLD, 11));
		labelHabEO.setBounds(10, 244, 57, 14);
		panelTelescopio.add(labelHabEO);
		
		paneHabEO = new JEditorPane();
		paneHabEO.setEditable(false);
		paneHabEO.setBounds(93, 245, 27, 10);
		panelTelescopio.add(paneHabEO);
		
		JPanel panelSec = new JPanel();
		panelSec.setLayout(null);
		panelSec.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Secundario", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 139)));
		panelSec.setBounds(22, 516, 134, 70);
		panelImagen.add(panelSec);
		
		JLabel lblAcerca = new JLabel("Aleja");
		lblAcerca.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAcerca.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAcerca.setBounds(10, 24, 57, 14);
		panelSec.add(lblAcerca);
		
		paneSecAleja = new JEditorPane();
		paneSecAleja.setEditable(false);
		paneSecAleja.setBounds(93, 25, 27, 10);
		panelSec.add(paneSecAleja);
		
		JLabel lblAcerca_1 = new JLabel("Acerca");
		lblAcerca_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAcerca_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAcerca_1.setBounds(10, 43, 57, 14);
		panelSec.add(lblAcerca_1);
		
		paneSecAcerca = new JEditorPane();
		paneSecAcerca.setEditable(false);
		paneSecAcerca.setBounds(93, 44, 27, 10);
		panelSec.add(paneSecAcerca);
		
		JPanel panelPlataf = new JPanel();
		panelPlataf.setLayout(null);
		panelPlataf.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Plataforma", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 128)));
		panelPlataf.setBounds(180, 48, 134, 110);
		panelImagen.add(panelPlataf);
		
		JLabel lblArriba = new JLabel("Arriba");
		lblArriba.setHorizontalAlignment(SwingConstants.RIGHT);
		lblArriba.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblArriba.setBounds(10, 24, 57, 14);
		panelPlataf.add(lblArriba);
		
		panePlatArr = new JEditorPane();
		panePlatArr.setEditable(false);
		panePlatArr.setBounds(93, 25, 27, 10);
		panelPlataf.add(panePlatArr);
		
		JLabel lblAbajo = new JLabel("Abajo");
		lblAbajo.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAbajo.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAbajo.setBounds(10, 43, 57, 14);
		panelPlataf.add(lblAbajo);
		
		panePlatAb = new JEditorPane();
		panePlatAb.setEditable(false);
		panePlatAb.setBounds(93, 44, 27, 10);
		panelPlataf.add(panePlatAb);
		
		JLabel lblAdentro = new JLabel("Adentro");
		lblAdentro.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAdentro.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAdentro.setBounds(10, 63, 57, 14);
		panelPlataf.add(lblAdentro);
		
		panePlatAd = new JEditorPane();
		panePlatAd.setEditable(false);
		panePlatAd.setBounds(93, 64, 27, 10);
		panelPlataf.add(panePlatAd);
		
		JLabel lblAfuera = new JLabel("Afuera");
		lblAfuera.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAfuera.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblAfuera.setBounds(10, 82, 57, 14);
		panelPlataf.add(lblAfuera);
		
		panePlatAf = new JEditorPane();
		panePlatAf.setEditable(false);
		panePlatAf.setBounds(93, 83, 27, 10);
		panelPlataf.add(panePlatAf);
		
		JPanel panel = new JPanel();
		panel.setLayout(null);
		panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Cupula", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 128)));
		panel.setBounds(180, 169, 134, 88);
		panelImagen.add(panel);
		
		JLabel lblDerecha = new JLabel("Derecha");
		lblDerecha.setHorizontalAlignment(SwingConstants.RIGHT);
		lblDerecha.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblDerecha.setBounds(10, 24, 57, 14);
		panel.add(lblDerecha);
		
		paneCupDer = new JEditorPane();
		paneCupDer.setEditable(false);
		paneCupDer.setBounds(93, 25, 27, 10);
		panel.add(paneCupDer);
		
		JLabel lblIzquierda = new JLabel("Izquierda");
		lblIzquierda.setHorizontalAlignment(SwingConstants.RIGHT);
		lblIzquierda.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblIzquierda.setBounds(10, 43, 57, 14);
		panel.add(lblIzquierda);
		
		paneCupIzq = new JEditorPane();
		paneCupIzq.setEditable(false);
		paneCupIzq.setBounds(93, 44, 27, 10);
		panel.add(paneCupIzq);
		
		JLabel lblVelLenta = new JLabel("Vel. Lenta");
		lblVelLenta.setHorizontalAlignment(SwingConstants.RIGHT);
		lblVelLenta.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblVelLenta.setBounds(10, 63, 57, 14);
		panel.add(lblVelLenta);
		
		paneVelLenta = new JEditorPane();
		paneVelLenta.setEditable(false);
		paneVelLenta.setBounds(93, 64, 27, 10);
		panel.add(paneVelLenta);
		
		JPanel panel_1 = new JPanel();
		panel_1.setLayout(null);
		panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Espectrografo", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 128)));
		panel_1.setBounds(180, 268, 134, 318);
		panelImagen.add(panel_1);
		
		JLabel lblMovmtos = new JLabel("Movmtos");
		lblMovmtos.setHorizontalAlignment(SwingConstants.RIGHT);
		lblMovmtos.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblMovmtos.setBounds(10, 24, 57, 14);
		panel_1.add(lblMovmtos);
		
		paneEspecMov = new JEditorPane();
		paneEspecMov.setEditable(false);
		paneEspecMov.setBounds(93, 25, 27, 10);
		panel_1.add(paneEspecMov);
		
		JLabel lblEjeY = new JLabel("Eje Y +");
		lblEjeY.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEjeY.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEjeY.setBounds(10, 43, 57, 14);
		panel_1.add(lblEjeY);
		
		paneEspecEjeYmas = new JEditorPane();
		paneEspecEjeYmas.setEditable(false);
		paneEspecEjeYmas.setBounds(93, 44, 27, 10);
		panel_1.add(paneEspecEjeYmas);
		
		JLabel lblEjeY_1 = new JLabel("Eje Y -");
		lblEjeY_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEjeY_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEjeY_1.setBounds(10, 63, 57, 14);
		panel_1.add(lblEjeY_1);
		
		paneEspecEjeYmenos = new JEditorPane();
		paneEspecEjeYmenos.setEditable(false);
		paneEspecEjeYmenos.setBounds(93, 64, 27, 10);
		panel_1.add(paneEspecEjeYmenos);
		
		JLabel lblEjeX = new JLabel("Eje X +");
		lblEjeX.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEjeX.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEjeX.setBounds(10, 82, 57, 14);
		panel_1.add(lblEjeX);
		
		paneEspecEjeXmas = new JEditorPane();
		paneEspecEjeXmas.setEditable(false);
		paneEspecEjeXmas.setBounds(93, 83, 27, 10);
		panel_1.add(paneEspecEjeXmas);
		
		paneEspecContinuo = new JEditorPane();
		paneEspecContinuo.setEditable(false);
		paneEspecContinuo.setBounds(93, 159, 27, 10);
		panel_1.add(paneEspecContinuo);
		
		paneEspecObtur = new JEditorPane();
		paneEspecObtur.setEditable(false);
		paneEspecObtur.setBounds(93, 140, 27, 10);
		panel_1.add(paneEspecObtur);
		
		paneEspecRanura = new JEditorPane();
		paneEspecRanura.setEditable(false);
		paneEspecRanura.setBounds(93, 120, 27, 10);
		panel_1.add(paneEspecRanura);
		
		paneEspecEjeXmenos = new JEditorPane();
		paneEspecEjeXmenos.setEditable(false);
		paneEspecEjeXmenos.setBounds(93, 101, 27, 10);
		panel_1.add(paneEspecEjeXmenos);
		
		JLabel lblEjeY_2 = new JLabel("Eje X -");
		lblEjeY_2.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEjeY_2.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEjeY_2.setBounds(10, 100, 57, 14);
		panel_1.add(lblEjeY_2);
		
		JLabel lblRanura = new JLabel("Ranura");
		lblRanura.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRanura.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRanura.setBounds(10, 119, 57, 14);
		panel_1.add(lblRanura);
		
		JLabel lblObturador = new JLabel("Obtr");
		lblObturador.setHorizontalAlignment(SwingConstants.RIGHT);
		lblObturador.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblObturador.setBounds(10, 139, 57, 14);
		panel_1.add(lblObturador);
		
		JLabel lblContinuo = new JLabel("Continuo");
		lblContinuo.setHorizontalAlignment(SwingConstants.RIGHT);
		lblContinuo.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblContinuo.setBounds(10, 158, 57, 14);
		panel_1.add(lblContinuo);
		
		JLabel lblLed = new JLabel("Led");
		lblLed.setHorizontalAlignment(SwingConstants.RIGHT);
		lblLed.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblLed.setBounds(10, 194, 57, 14);
		panel_1.add(lblLed);
		
		JLabel lblCompar = new JLabel("Compar");
		lblCompar.setHorizontalAlignment(SwingConstants.RIGHT);
		lblCompar.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblCompar.setBounds(10, 175, 57, 14);
		panel_1.add(lblCompar);
		
		paneEspecCompar = new JEditorPane();
		paneEspecCompar.setEditable(false);
		paneEspecCompar.setBounds(93, 176, 27, 10);
		panel_1.add(paneEspecCompar);
		
		paneEspecLed = new JEditorPane();
		paneEspecLed.setEditable(false);
		paneEspecLed.setBounds(93, 195, 27, 10);
		panel_1.add(paneEspecLed);
		
		JLabel lblEntFiltro = new JLabel("Ent Filtro");
		lblEntFiltro.setHorizontalAlignment(SwingConstants.RIGHT);
		lblEntFiltro.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblEntFiltro.setBounds(10, 290, 57, 14);
		panel_1.add(lblEntFiltro);
		
		JLabel lblFiltro_1 = new JLabel("Filtro 2");
		lblFiltro_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFiltro_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblFiltro_1.setBounds(10, 271, 57, 14);
		panel_1.add(lblFiltro_1);
		
		JLabel lblFiltro = new JLabel("Filtro 1");
		lblFiltro.setHorizontalAlignment(SwingConstants.RIGHT);
		lblFiltro.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblFiltro.setBounds(10, 254, 57, 14);
		panel_1.add(lblFiltro);
		
		JLabel lblRed_1 = new JLabel("Red -");
		lblRed_1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRed_1.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRed_1.setBounds(10, 235, 57, 14);
		panel_1.add(lblRed_1);
		
		JLabel lblRed = new JLabel("Red +");
		lblRed.setHorizontalAlignment(SwingConstants.RIGHT);
		lblRed.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblRed.setBounds(10, 215, 57, 14);
		panel_1.add(lblRed);
		
		paneEspecRedmas = new JEditorPane();
		paneEspecRedmas.setEditable(false);
		paneEspecRedmas.setBounds(93, 216, 27, 10);
		panel_1.add(paneEspecRedmas);
		
		paneEspecRedmenos = new JEditorPane();
		paneEspecRedmenos.setEditable(false);
		paneEspecRedmenos.setBounds(93, 236, 27, 10);
		panel_1.add(paneEspecRedmenos);
		
		paneEspecFiltro1 = new JEditorPane();
		paneEspecFiltro1.setEditable(false);
		paneEspecFiltro1.setBounds(93, 255, 27, 10);
		panel_1.add(paneEspecFiltro1);
		
		paneEspecFiltro2 = new JEditorPane();
		paneEspecFiltro2.setEditable(false);
		paneEspecFiltro2.setBounds(93, 272, 27, 10);
		panel_1.add(paneEspecFiltro2);
		
		paneEspecEntFiltro = new JEditorPane();
		paneEspecEntFiltro.setEditable(false);
		paneEspecEntFiltro.setBounds(93, 291, 27, 10);
		panel_1.add(paneEspecEntFiltro);
		
		JLabel lblInterfazDeControl = new JLabel("INTERFAZ DE CONTROL");
		lblInterfazDeControl.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblInterfazDeControl.setBounds(88, 11, 178, 17);
		panelImagen.add(lblInterfazDeControl);
		
		JPanel panelAlfa = new JPanel();
		panelAlfa.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panelAlfa.setBounds(432, 42, 329, 81);
		getContentPane().add(panelAlfa);
		panelAlfa.setLayout(null);
		
		textAlfaSeg = new JTextArea();
		textAlfaSeg.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent arg0) {
				Integer segAlfa = Integer.parseInt(textAlfaSeg.getText());
				Integer val =0;
				if(arg0.getKeyCode() == KeyEvent.VK_UP)
				{
					val = segAlfa + 1; 
					actualizarValorEncoder(EncoderNombre.ALFA);
				}
				else if(arg0.getKeyCode() == KeyEvent.VK_DOWN)
				{
					val = segAlfa -1; 
					actualizarValorEncoder(EncoderNombre.ALFA);
				}
				textAlfaSeg.setText(String.format("%02d", val));
			}
		});
		textAlfaSeg.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent arg0) {
				
				if(!autoMode)
				{
					Integer notches = arg0.getWheelRotation();
					Integer segAlfa = Integer.parseInt(textAlfaSeg.getText());
					Integer val =0;
					if(segAlfa>=0 && segAlfa <=59)
						{
						
							val = segAlfa - notches;
							if(val == -1)
							{
								val = 59;
								
							}
							
							if(val == 60)
							{
								val = 00;
								
							}
							
						}
					
					//textAlfaSeg.setText(String.format("%02d", val));
					//actualizarValorEncoder(EncoderNombre.ALFA);
					encoderAlfa.setSegundos(val);
				}
				
			}
		});
		textAlfaSeg.setBackground(UIManager.getColor("Button.background"));
		textAlfaSeg.setFont(fuente7Seg);
		textAlfaSeg.setText("00");
		textAlfaSeg.setBounds(253, 11, 67, 60);
		panelAlfa.add(textAlfaSeg);
		
		textAlfaMin = new JTextArea();
		textAlfaMin.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent arg0) {
				if(!autoMode)
				{
					Integer notches = arg0.getWheelRotation();
					Integer minAlfa = Integer.parseInt(textAlfaMin.getText());
					Integer val =0;
					if(minAlfa>=0 && minAlfa <=59)
						{
						
							val = minAlfa - notches;
							if(val == -1)
							{
								val = 59;
								
							}
							
							if(val == 60)
							{
								val = 00;
								
							}
							
						}
					
					//textAlfaMin.setText(String.format("%02d", val));
					//actualizarValorEncoder(EncoderNombre.ALFA);
					encoderAlfa.setMinutos(val);
				}
				
			}
		});
		textAlfaMin.setBackground(UIManager.getColor("Button.background"));
		textAlfaMin.setText("00");
		//textAlfaMin.setFont(new Font("DS-Digital", Font.BOLD, 54));
		textAlfaMin.setFont(fuente7Seg);
		textAlfaMin.setBounds(169, 11, 67, 60);
		panelAlfa.add(textAlfaMin);
		
		textAlfaGrad = new JTextArea();
		textAlfaGrad.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				if(!autoMode)
				{
					//System.out.println("alfa: " + scoba.getTelescopio().getAngHorarioRad());
					Integer notches = e.getWheelRotation();
					//Integer grad = Integer.parseInt(textAlfaGrad.getText());
					Integer grad = encoderAlfa.getGrados();
					Integer signo = encoderAlfa.getSigno();
					//grad = grad * encoderAlfa.getSigno();
					//System.out.println(grad * signo);
					Integer val =0;
					if((grad * signo) >=-90 && (grad * signo) <=90)
						{
						
							val = grad * signo - notches;
							if(val == -90)
							{
								val = 0;
								
							}
							
							if(val == 90)
							{
								val = 00;
								
							}
							
						}
					
					//textAlfaGrad.setText(String.format("%03d", val));
					//actualizarValorEncoder(EncoderNombre.ALFA);
					encoderAlfa.setSigno((val < 0) ? -1 : 1);
					encoderAlfa.setGrados(Math.abs(val));
				}
				
			}
		});
		textAlfaGrad.setBackground(UIManager.getColor("Button.background"));
		textAlfaGrad.setText("000");
		textAlfaGrad.setFont(fuente7Seg);
		textAlfaGrad.setBounds(61, 11, 85, 60);
		panelAlfa.add(textAlfaGrad);
		
		textAlfaSign = new JTextArea();
		textAlfaSign.setEditable(false);
		textAlfaSign.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				if(!autoMode)
				{
					if(encoderAlfa.getSigno().equals(-1))
					{
						encoderAlfa.setSigno(1);
					}
					else
					{
						encoderAlfa.setSigno(-1);
					}
					//actualizarValorEncoder(EncoderNombre.ALFA);
				}
				
			}
		});
		textAlfaSign.setBackground(UIManager.getColor("Button.background"));
		textAlfaSign.setFont(fuente7Seg);
		textAlfaSign.setBounds(24, 11, 33, 60);
		panelAlfa.add(textAlfaSign);
		
		JTextArea textArea_5 = new JTextArea();
		textArea_5.setEditable(false);
		textArea_5.setText(":");
		textArea_5.setFont(new Font("DFKai-SB", Font.BOLD, 38));
		textArea_5.setBackground(SystemColor.menu);
		textArea_5.setBounds(143, 11, 23, 60);
		panelAlfa.add(textArea_5);
		
		JTextArea textArea_4 = new JTextArea();
		textArea_4.setEditable(false);
		textArea_4.setText(":");
		textArea_4.setFont(new Font("DFKai-SB", Font.BOLD, 38));
		textArea_4.setBackground(SystemColor.menu);
		textArea_4.setBounds(230, 11, 23, 60);
		panelAlfa.add(textArea_4);
		
		JLabel lblEncoderAlfa = new JLabel("ENCODER ALFA (AR)");
		lblEncoderAlfa.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblEncoderAlfa.setBounds(523, 21, 157, 17);
		getContentPane().add(lblEncoderAlfa);
		
		JPanel panel_2 = new JPanel();
		panel_2.setLayout(null);
		panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panel_2.setBounds(432, 154, 329, 81);
		getContentPane().add(panel_2);
		
		textDeltaSeg = new JTextArea();
		textDeltaSeg.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				if(!autoMode)
				{
					Integer notches = e.getWheelRotation();
					//Integer segDelta = Integer.parseInt(textDeltaSeg.getText());
					Integer segDelta = encoderDelta.getSegundos();
					//System.out.println("encDelta: " + segDelta);
					Integer val =0;
					if(segDelta>=0 && segDelta <=59)
						{
						
							val = segDelta - notches;
							if(val == -1)
							{
								val = 59;
								
							}
							
							if(val == 60)
							{
								val = 00;
								
							}
							
						}
					
					//textDeltaSeg.setText(String.format("%02d", val));
					//actualizarValorEncoder(EncoderNombre.DELTA);
					encoderDelta.setSegundos(val);
					//System.out.println("val: " + val);
					//encoderDelta.actualizarEncoderDelta(Angulo.SEGUNDOS);
				}
				
			}
		});
		textDeltaSeg.setText("00");
		textDeltaSeg.setFont(fuente7Seg);
		textDeltaSeg.setBackground(SystemColor.menu);
		textDeltaSeg.setBounds(253, 11, 67, 60);
		panel_2.add(textDeltaSeg);
		
		textDeltaMin = new JTextArea();
		textDeltaMin.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				if(!autoMode)
				{
					Integer notches = e.getWheelRotation();
					Integer minDelta = Integer.parseInt(textDeltaMin.getText());
					Integer val =0;
					if(minDelta>=0 && minDelta <=59)
						{
						
							val = minDelta - notches;
							if(val == -1)
							{
								val = 59;
								
							}
							
							if(val == 60)
							{
								val = 00;
								
							}
							
						}
					encoderDelta.setMinutos(val);
					
					//textDeltaMin.setText(String.format("%02d", val));
					//actualizarValorEncoder(EncoderNombre.DELTA);
				}
				
			}
		});
		textDeltaMin.setText("00");
		textDeltaMin.setFont(fuente7Seg);
		textDeltaMin.setBackground(SystemColor.menu);
		textDeltaMin.setBounds(169, 11, 67, 60);
		panel_2.add(textDeltaMin);
		
		textDeltaGrad = new JTextArea();
		textDeltaGrad.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				if(!autoMode)
				{
					//System.out.println("alfa: " + scoba.getTelescopio().getAngHorarioRad());
					Integer notches = e.getWheelRotation();
					//Integer grad = Integer.parseInt(textAlfaGrad.getText());
					Integer grad = encoderDelta.getGrados();
					Integer signo = encoderDelta.getSigno();
					//grad = grad * encoderAlfa.getSigno();
					//System.out.println(grad * signo);
					Integer val =0;
					if((grad * signo) >=-90 && (grad * signo) <=90)
						{
						
							val = grad * signo - notches;
							if(val == -90)
							{
								val = 0;
								
							}
							
							if(val == 90)
							{
								val = 00;
								
							}
							
						}
					
					//textAlfaGrad.setText(String.format("%03d", val));
					//actualizarValorEncoder(EncoderNombre.ALFA);
					encoderDelta.setSigno((val < 0) ? -1 : 1);
					encoderDelta.setGrados(Math.abs(val));
				}
				
			}
		});
		textDeltaGrad.setText("031");
		textDeltaGrad.setFont(fuente7Seg);
		textDeltaGrad.setBackground(SystemColor.menu);
		textDeltaGrad.setBounds(61, 11, 83, 60);
		panel_2.add(textDeltaGrad);
		
		textDeltaSign = new JTextArea();
		textDeltaSign.setEditable(false);
		textDeltaSign.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if(!autoMode)
				{
					if(encoderDelta.getSigno().equals(-1))
					{
						encoderDelta.setSigno(1);
					}
					else
					{
						encoderDelta.setSigno(-1);
					}
					//actualizarValorEncoder(EncoderNombre.DELTA);
				}
				
			}
			
		});
		textDeltaSign.setText("-");
		textDeltaSign.setFont(fuente7Seg);
		textDeltaSign.setBackground(SystemColor.menu);
		textDeltaSign.setBounds(24, 11, 33, 60);
		panel_2.add(textDeltaSign);
		
		JTextArea textArea_10 = new JTextArea();
		textArea_10.setEditable(false);
		textArea_10.setText(":");
		textArea_10.setFont(new Font("DFKai-SB", Font.BOLD, 38));
		textArea_10.setBackground(SystemColor.menu);
		textArea_10.setBounds(143, 11, 23, 60);
		panel_2.add(textArea_10);
		
		JTextArea textArea_11 = new JTextArea();
		textArea_11.setEditable(false);
		textArea_11.setText(":");
		textArea_11.setFont(new Font("DFKai-SB", Font.BOLD, 38));
		textArea_11.setBackground(SystemColor.menu);
		textArea_11.setBounds(230, 11, 23, 60);
		panel_2.add(textArea_11);
		
		JLabel lblEncoderDelta = new JLabel("ENCODER DELTA (DEC)");
		lblEncoderDelta.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblEncoderDelta.setBounds(523, 134, 165, 17);
		getContentPane().add(lblEncoderDelta);
		
		JPanel panel_adc = new JPanel();
		panel_adc.setBorder(new TitledBorder(null, "ADCs", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_adc.setBounds(418, 320, 343, 313);
		getContentPane().add(panel_adc);
		panel_adc.setLayout(null);
		
		textFunc = new JTextField();
		textFunc.setHorizontalAlignment(SwingConstants.RIGHT);
		textFunc.setText("170");
		textFunc.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textFunc.setBounds(166, 18, 36, 20);
		panel_adc.add(textFunc);
		textFunc.setColumns(10);
		
		JLabel lblFunc = new JLabel("16 - Funcionamiento: ");
		lblFunc.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblFunc.setBounds(22, 21, 134, 14);
		panel_adc.add(lblFunc);
		
		JLabel lblFines = new JLabel("32 - Fines de Carrera: ");
		lblFines.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblFines.setBounds(22, 46, 134, 14);
		panel_adc.add(lblFines);
		
		JLabel lbl2lsb = new JLabel("64  - 2 lsb Conv A/D: ");
		lbl2lsb.setFont(new Font("Tahoma", Font.BOLD, 12));
		lbl2lsb.setBounds(22, 71, 134, 14);
		panel_adc.add(lbl2lsb);
		
		JLabel lblTempExt = new JLabel("130 - Temp Ext.: ");
		lblTempExt.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblTempExt.setBounds(22, 96, 134, 14);
		panel_adc.add(lblTempExt);
		
		JLabel lblTempEspejo = new JLabel("146 - Temp. Espejo: ");
		lblTempEspejo.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblTempEspejo.setBounds(22, 121, 134, 14);
		panel_adc.add(lblTempEspejo);
		
		JLabel lblPlatARAB = new JLabel("162 - Plataf AR/AB: ");
		lblPlatARAB.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblPlatARAB.setBounds(22, 146, 134, 14);
		panel_adc.add(lblPlatARAB);
		
		JLabel lblPlataf = new JLabel("178 - Plataf AD/AF: ");
		lblPlataf.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblPlataf.setBounds(22, 171, 134, 14);
		panel_adc.add(lblPlataf);
		
		JLabel lblCupula = new JLabel("194 - Cupula: ");
		lblCupula.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblCupula.setBounds(22, 196, 134, 14);
		panel_adc.add(lblCupula);
		
		JLabel lblEspec = new JLabel("210 - Espec X:");
		lblEspec.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblEspec.setBounds(22, 221, 134, 14);
		panel_adc.add(lblEspec);
		
		JLabel lblEspec_1 = new JLabel("226 - Espec Y: ");
		lblEspec_1.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblEspec_1.setBounds(22, 246, 134, 14);
		panel_adc.add(lblEspec_1);
		
		JLabel lblEspec_2 = new JLabel("242 - Espec RED: ");
		lblEspec_2.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblEspec_2.setBounds(22, 271, 134, 14);
		panel_adc.add(lblEspec_2);
		
		textFines = new JTextField();
		textFines.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent arg0) {
				Integer notches = arg0.getWheelRotation();
				Integer valLabel = Integer.parseInt(textFines.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textFines.setText(String.format("%d", val));
			}
		});
		textFines.setText("0");
		textFines.setHorizontalAlignment(SwingConstants.RIGHT);
		textFines.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textFines.setColumns(10);
		textFines.setBounds(166, 44, 36, 20);
		panel_adc.add(textFines);
		
		text2lsb = new JTextField();
		text2lsb.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent arg0) {
				Integer notches = arg0.getWheelRotation();
				Integer valLabel = Integer.parseInt(text2lsb.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - (notches*64);
						if(val == -64)
						{
							val = 192;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				text2lsb.setText(String.format("%d", val));
				//updateValues10b();
			}
		});
		text2lsb.setForeground(Color.RED);
		text2lsb.setText("0");
		text2lsb.setHorizontalAlignment(SwingConstants.RIGHT);
		text2lsb.setFont(new Font("Tahoma", Font.PLAIN, 12));
		text2lsb.setColumns(10);
		text2lsb.setBounds(166, 69, 36, 20);
		panel_adc.add(text2lsb);
		
		textTempExt = new JTextField();
		textTempExt.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent arg0) {
				Integer notches = arg0.getWheelRotation();
				Integer valLabel = Integer.parseInt(textTempExt.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textTempExt.setText(String.format("%d", val));
			}
		});
		textTempExt.setText("0");
		textTempExt.setHorizontalAlignment(SwingConstants.RIGHT);
		textTempExt.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textTempExt.setColumns(10);
		textTempExt.setBounds(166, 94, 36, 20);
		panel_adc.add(textTempExt);
		
		textTempEspejo = new JTextField();
		textTempEspejo.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textTempEspejo.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textTempEspejo.setText(String.format("%d", val));
			}
		});
		textTempEspejo.setText("0");
		textTempEspejo.setHorizontalAlignment(SwingConstants.RIGHT);
		textTempEspejo.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textTempEspejo.setColumns(10);
		textTempEspejo.setBounds(166, 119, 36, 20);
		panel_adc.add(textTempEspejo);
		
		textPlatARAB = new JTextField();
		textPlatARAB.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textPlatARAB.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textPlatARAB.setText(String.format("%d", val));
			}
		});
		textPlatARAB.setText("127");
		textPlatARAB.setHorizontalAlignment(SwingConstants.RIGHT);
		textPlatARAB.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textPlatARAB.setColumns(10);
		textPlatARAB.setBounds(166, 144, 36, 20);
		panel_adc.add(textPlatARAB);
		
		textPlatADAF = new JTextField();
		textPlatADAF.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textPlatADAF.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textPlatADAF.setText(String.format("%d", val));
			}
		});
		textPlatADAF.setText("0");
		textPlatADAF.setHorizontalAlignment(SwingConstants.RIGHT);
		textPlatADAF.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textPlatADAF.setColumns(10);
		textPlatADAF.setBounds(166, 169, 36, 20);
		panel_adc.add(textPlatADAF);
		
		textCupula = new JTextField();
		textCupula.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				updateCupula10b();
			}
		});
		textCupula.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				updateCupula10b();
			}
		});
		
		textCupula.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textCupula.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textCupula.setText(String.format("%d", val));
				updateCupula10b();
				
			}
		});
		textCupula.setText("220");
		textCupula.setHorizontalAlignment(SwingConstants.RIGHT);
		textCupula.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textCupula.setColumns(10);
		textCupula.setBounds(166, 194, 36, 20);
		panel_adc.add(textCupula);
		
		textEspecX = new JTextField();
		textEspecX.setEnabled(false);
		textEspecX.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				updateEspecX10b();
			}
		});
		textEspecX.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				updateEspecX10b();
			}
		});
		textEspecX.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textEspecX.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textEspecX.setText(String.format("%d", val));
				updateEspecX10b();
			}
		});
		textEspecX.setText("0");
		textEspecX.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecX.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textEspecX.setColumns(10);
		textEspecX.setBounds(166, 219, 36, 20);
		panel_adc.add(textEspecX);
		
		textEspecY = new JTextField();
		textEspecY.setEnabled(false);
		textEspecY.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				updateEspecY10b();
			}
		});
		textEspecY.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				updateEspecY10b();
			}
		});
		textEspecY.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textEspecY.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textEspecY.setText(String.format("%d", val));
				updateEspecY10b();
			}
		});
		textEspecY.setText("0");
		textEspecY.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecY.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textEspecY.setColumns(10);
		textEspecY.setBounds(166, 244, 36, 20);
		panel_adc.add(textEspecY);
		
		textEspecRed = new JTextField();
		textEspecRed.setEnabled(false);
		textEspecRed.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				updateEspecRed10b();
			}
		});
		textEspecRed.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				updateEspecRed10b();
			}
		});
		textEspecRed.addMouseWheelListener(new MouseWheelListener() {
			public void mouseWheelMoved(MouseWheelEvent e) {
				Integer notches = e.getWheelRotation();
				Integer valLabel = Integer.parseInt(textEspecRed.getText());
				Integer val =0;
				if(valLabel>=0 && valLabel <=256)
					{
					
						val = valLabel - notches;
						if(val == -1)
						{
							val = 255;
							
						}
						
						if(val == 256)
						{
							val = 0;
							
						}
						
					}
				
				textEspecRed.setText(String.format("%d", val));
				updateEspecRed10b();
			}
		});
		textEspecRed.setText("0");
		textEspecRed.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecRed.setFont(new Font("Tahoma", Font.PLAIN, 12));
		textEspecRed.setColumns(10);
		textEspecRed.setBounds(166, 269, 36, 20);
		panel_adc.add(textEspecRed);
		
		textCupula10b = new JTextField();
		textCupula10b.setHorizontalAlignment(SwingConstants.RIGHT);
		textCupula10b.setText("0");
		textCupula10b.setEditable(false);
		textCupula10b.setBounds(212, 194, 48, 20);
		panel_adc.add(textCupula10b);
		textCupula10b.setColumns(10);
		
		textEspecX10b = new JTextField();
		textEspecX10b.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecX10b.setText("0");
		textEspecX10b.setEditable(false);
		textEspecX10b.setColumns(10);
		textEspecX10b.setBounds(212, 219, 48, 20);
		panel_adc.add(textEspecX10b);
		
		textEspecY10b = new JTextField();
		textEspecY10b.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecY10b.setText("0");
		textEspecY10b.setEditable(false);
		textEspecY10b.setColumns(10);
		textEspecY10b.setBounds(212, 244, 48, 20);
		panel_adc.add(textEspecY10b);
		
		textEspecRed10b = new JTextField();
		textEspecRed10b.setText("0");
		textEspecRed10b.setHorizontalAlignment(SwingConstants.RIGHT);
		textEspecRed10b.setEditable(false);
		textEspecRed10b.setColumns(10);
		textEspecRed10b.setBounds(212, 269, 48, 20);
		panel_adc.add(textEspecRed10b);
		
		JPanel panel_tools = new JPanel();
		panel_tools.setBorder(new TitledBorder(null, "Tools", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_tools.setBounds(418, 246, 343, 60);
		getContentPane().add(panel_tools);
		panel_tools.setLayout(null);
		
		chckbxAutoMode = new JCheckBox("Modo Auto");
		chckbxAutoMode.setToolTipText("Activar/Desactivar Modo Autom\u00E1tico");
		chckbxAutoMode.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(chckbxAutoMode.isSelected())
				{
					//getTextCupula().setEditable(false);
					activarAutoCupula();
					activarAutoPlataforma();
					activarAutoTelescopio();
					actualizarValorEncoder(EncoderNombre.ALFA);
					actualizarValorEncoder(EncoderNombre.DELTA);
				}
				else
				{
					setAutoMode(false);
					//getTextCupula().setEditable(true);
				}
				
			}
		});
		chckbxAutoMode.setBounds(20, 19, 97, 23);
		panel_tools.add(chckbxAutoMode);
		
		btnConnect = new JButton("CONECTAR");
		btnConnect.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				int opcion = JOptionPane.showConfirmDialog(btnConnect, Mensajes.QUESTION_SIMULATOR_ACTIVAR.getMsg(), 
						Mensajes.INFO_SIMULATOR_ACTIVAR.getMsg() , JOptionPane.YES_NO_OPTION);
				
				if(opcion == JOptionPane.YES_OPTION)
				{
					scoba.getLecturas().activarLecturas(false);
					scoba.getControlador().setFlagSimulador(true);
					updater.start();
					btnConnect.setEnabled(false);
					encoderDelta.setGrados(31);
					encoderDelta.setMinutos(0);
					encoderDelta.setSegundos(0);
					encoderDelta.setSigno(-1);
					//encoderAlfa.calcularGradMinSeg();
					//encoderDelta.calcularGradMinSeg();
					actualizarValorEncoder(EncoderNombre.ALFA);
					actualizarValorEncoder(EncoderNombre.DELTA);
					getEncoderAlfa().calcularAnguloEnSegundosThis();
					getEncoderDelta().calcularAnguloEnSegundosThis();
					updateCupula10b();
					updateValues10b();
					
				}
				else
				{
					
				}
				
				
				
			}
		});
		btnConnect.setBounds(123, 19, 89, 23);
		panel_tools.add(btnConnect);
		
		JButton btnRestart = new JButton("RESTART");
		btnRestart.setEnabled(false);
		btnRestart.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Integer segAlfa = Integer.parseInt(textAlfaSeg.getText());
				Integer minAlfa = Integer.parseInt(textAlfaMin.getText());
				Integer gradAlfa = Integer.parseInt(textAlfaGrad.getText());
				Integer signo = textAlfaSign.getText().isEmpty() ? 1 : -1;
				
				encoderAlfa.calcularAnguloEnSegundos( gradAlfa, minAlfa, segAlfa, signo);
				encoderAlfa.calcularGradMinSeg();
				//System.out.println(encoderAlfa.getAngulo());
				//System.out.println(encoderAlfa.getGrados() + " " + encoderAlfa.getMinutos() + " " + encoderAlfa.getSegundos());
				
			}
		});
		btnRestart.setBounds(228, 19, 89, 23);
		panel_tools.add(btnRestart);
	
	
		
	}
	
	
	public JPanel getPanelImagen() {
		return panelImagen;
	}
	public JTextArea getTextAlfaSeg() {
		return textAlfaSeg;
	}
	public JEditorPane getPaneVelLenta() {
		return paneVelLenta;
	}
	
	public void setPaneOnOff(JEditorPane pane, boolean cond)
	{
		if(cond)
			pane.setBackground(Color.RED);
		else
			pane.setBackground(Color.WHITE);
	}
	
	public void setPaneVelLenta(boolean cond)
	{
		if(cond)
			this.paneVelLenta.setBackground(Color.RED);
		else
			this.paneVelLenta.setBackground(Color.WHITE);
	}
	public JEditorPane getPaneCupIzq() {
		return paneCupIzq;
	}
	public JEditorPane getPaneCupDer() {
		return paneCupDer;
	}
	public JEditorPane getPanePlatAf() {
		return panePlatAf;
	}
	public JEditorPane getPanePlatAd() {
		return panePlatAd;
	}
	public JEditorPane getPanePlatAb() {
		return panePlatAb;
	}
	public JEditorPane getPanePlatArr() {
		return panePlatArr;
	}
	public JEditorPane getPaneTablero() {
		return paneTablero;
	}
	public JEditorPane getPanePulsador() {
		return panePulsador;
	}
	public JEditorPane getPaneReloj() {
		return paneReloj;
	}
	public JEditorPane getPaneRampa() {
		return paneConsRampa;
	}
	public JEditorPane getPaneSecAleja() {
		return paneSecAleja;
	}
	public JEditorPane getPaneSecAcerca() {
		return paneSecAcerca;
	}
	public JEditorPane getPaneVelTel() {
		return paneVelTel;
	}
	public JEditorPane getPaneTelDeclin() {
		return paneTelDeclin;
	}
	public JEditorPane getPaneTelNor() {
		return paneTelNor;
	}
	public JEditorPane getPaneTelSur() {
		return paneTelSur;
	}
	public JEditorPane getPaneTelEste() {
		return paneTelEste;
	}
	public JEditorPane getPaneTelRE() {
		return paneTelRE;
	}
	public JEditorPane getPaneTelOeste() {
		return paneTelOeste;
	}
	public JEditorPane getPaneTelRO() {
		return paneTelRO;
	}
	public JEditorPane getPaneTelGuiado() {
		return paneTelGuiado;
	}
	public JEditorPane getPaneTelCalado() {
		return paneTelCalado;
	}
	public JEditorPane getPaneEspecEntFiltro() {
		return paneEspecEntFiltro;
	}
	public JEditorPane getPaneEspecFiltro2() {
		return paneEspecFiltro2;
	}
	public JEditorPane getPaneEspecFiltro1() {
		return paneEspecFiltro1;
	}
	public JEditorPane getPaneEspecRedmenos() {
		return paneEspecRedmenos;
	}
	public JEditorPane getPaneEspecRedmas() {
		return paneEspecRedmas;
	}
	public JEditorPane getPaneEspecLed() {
		return paneEspecLed;
	}
	public JEditorPane getPaneEspecCompar() {
		return paneEspecCompar;
	}
	public JEditorPane getPaneEspecContinuo() {
		return paneEspecContinuo;
	}
	public JEditorPane getPaneEspecObtur() {
		return paneEspecObtur;
	}
	public JEditorPane getPaneEspecRanura() {
		return paneEspecRanura;
	}
	public JEditorPane getPaneEspecEjeXmenos() {
		return paneEspecEjeXmenos;
	}
	public JEditorPane getPaneEspecEjeXmas() {
		return paneEspecEjeXmas;
	}
	public JEditorPane getPaneEspecEjeYmenos() {
		return paneEspecEjeYmenos;
	}
	public JEditorPane getPaneEspecEjeYmas() {
		return paneEspecEjeYmas;
	}
	public JEditorPane getPaneEspecMov() {
		return paneEspecMov;
	}
	public JTextArea getTextAlfaMin() {
		return textAlfaMin;
	}
	public JTextArea getTextAlfaGrad() {
		return textAlfaGrad;
	}
	public JTextArea getTextAlfaSign() {
		return textAlfaSign;
	}
	public JTextArea getTextDeltaSeg() {
		return textDeltaSeg;
	}
	public JTextArea getTextDeltaMin() {
		return textDeltaMin;
	}
	public JTextArea getTextDeltaGrad() {
		return textDeltaGrad;
	}
	public JTextArea getTextDeltaSign() {
		return textDeltaSign;
	}
	public JTextField getTextFunc() {
		return textFunc;
	}
	public JTextField getTextFines() {
		return textFines;
	}
	public JTextField getText2lsb() {
		return text2lsb;
	}
	public JTextField getTextTempExt() {
		return textTempExt;
	}
	public JTextField getTextTempEspejo() {
		return textTempEspejo;
	}
	public JTextField getTextPlatARAB() {
		return textPlatARAB;
	}
	public JTextField getTextPlatADAF() {
		return textPlatADAF;
	}
	public JTextField getTextCupula() {
		return textCupula;
	}
	public JTextField getTextEspecX() {
		return textEspecX;
	}
	public JTextField getTextEspecY() {
		return textEspecY;
	}
	public JTextField getTextEspecRed() {
		return textEspecRed;
	}
	
	public void setTextFunc(JTextField textFunc)
	{
		this.textFunc = textFunc;
	}

	public void setTextFines(JTextField textFines)
	{
		this.textFines = textFines;
	}

	public void setTextTempExt(JTextField textTempExt)
	{
		this.textTempExt = textTempExt;
	}

	public void setTextTempEspejo(JTextField textTempEspejo)
	{
		this.textTempEspejo = textTempEspejo;
	}

	public void setTextPlatARAB(JTextField textPlatARAB)
	{
		this.textPlatARAB = textPlatARAB;
	}

	public void setTextPlatADAF(JTextField textPlatADAF)
	{
		this.textPlatADAF = textPlatADAF;
	}

	public void setTextCupula(JTextField textCupula)
	{
		this.textCupula = textCupula;
	}

	public void setTextEspecX(JTextField textEspecX)
	{
		this.textEspecX = textEspecX;
	}

	public void setTextEspecY(JTextField textEspecY)
	{
		this.textEspecY = textEspecY;
	}

	public void setTextEspecRed(JTextField textEspecRed)
	{
		this.textEspecRed = textEspecRed;
	}
	public JTextField getTextCupula10b() {
		return textCupula10b;
	}
	
	public void updateValues10b()
	{
		Integer cupula10b = 0;
		Integer especX10b = 0;
		Integer especY10b = 0;
		Integer especRed10b = 0;
		Integer val8msb = 0;
		Integer val2lsb = 0;
		Integer valTemp = 0;
		
		valTemp = Integer.parseInt(this.getTextCupula().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		cupula10b = val8msb + val2lsb;
		this.getTextCupula10b().setText(cupula10b.toString());
		
		valTemp = Integer.parseInt(this.getTextEspecX().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especX10b = val8msb + val2lsb;
		this.getTextEspecX10b().setText(especX10b.toString());
		
		valTemp = Integer.parseInt(this.getTextEspecY().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especY10b = val8msb + val2lsb;
		this.getTextEspecY10b().setText(especY10b.toString());
		
		valTemp = Integer.parseInt(this.getTextEspecRed().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especRed10b = val8msb + val2lsb;
		this.getTextEspecRed10b().setText(especRed10b.toString());
		
		
	}
	
	public synchronized void updateCupula10b()
	{
		Integer cupula10b = 0;
		
		Integer val8msb = 0;
		Integer val2lsb = 0;
		Integer valTemp = 0;
		
		valTemp = Integer.parseInt(this.getTextCupula().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		cupula10b = val8msb + val2lsb;
		//System.out.println(cupula10b);
		this.getTextCupula10b().setText(cupula10b.toString());
	}
	
	public void updateEspecRed10b()
	{
		
		Integer especRed10b = 0;
		Integer val8msb = 0;
		Integer val2lsb = 0;
		Integer valTemp = 0;
		
		valTemp = Integer.parseInt(this.getTextEspecRed().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especRed10b = val8msb + val2lsb;
		this.getTextEspecRed10b().setText(especRed10b.toString());
	}
	
	public void updateEspecX10b()
	{
		
		Integer especX10b = 0;
	
		Integer val8msb = 0;
		Integer val2lsb = 0;
		Integer valTemp = 0;
		
		valTemp = Integer.parseInt(this.getTextEspecX().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especX10b = val8msb + val2lsb;
		this.getTextEspecX10b().setText(especX10b.toString());
	}
	
	public void updateEspecY10b()
	{
		
		Integer especY10b = 0;
	
		Integer val8msb = 0;
		Integer val2lsb = 0;
		Integer valTemp = 0;
		
		valTemp = Integer.parseInt(this.getTextEspecY().getText(),10);
		val8msb = valTemp << 2;
		valTemp = Integer.parseInt(this.getText2lsb().getText(),10);
		val2lsb = valTemp >> 6;
		especY10b = val8msb + val2lsb;
		this.getTextEspecY10b().setText(especY10b.toString());
	}
	
	
	public JTextField getTextEspecX10b() {
		return textEspecX10b;
	}
	public JTextField getTextEspecY10b() {
		return textEspecY10b;
	}
	public JTextField getTextEspecRed10b() {
		return textEspecRed10b;
	}
	public JTextField getTextFieldRampa() {
		return textFieldVelTel;
	}

	public void setTextFieldRampa(JTextField textFieldRampa)
	{
		this.textFieldVelTel = textFieldRampa;
	}

	public EncoderSimulator getEncoderAlfa()
	{
		return encoderAlfa;
	}

	public void setEncoderAlfa(EncoderSimulator encoderAlfa)
	{
		this.encoderAlfa = encoderAlfa;
	}

	public EncoderSimulator getEncoderDelta()
	{
		return encoderDelta;
	}

	public void setEncoderDelta(EncoderSimulator encoderDelta)
	{
		this.encoderDelta = encoderDelta;
	}
	public JEditorPane getPaneInterfaz0() {
		return paneInterfaz0;
	}
	public JEditorPane getPaneInterfaz1() {
		return paneInterfaz1;
	}

	public JEditorPane getPaneConsRampa() {
		return paneConsRampa;
	}

	public void setPaneConsRampa(JEditorPane paneConsRampa) {
		this.paneConsRampa = paneConsRampa;
	}

	public void setPaneTablero(JEditorPane paneTablero) {
		this.paneTablero = paneTablero;
	}

	public void setPanePulsador(JEditorPane panePulsador) {
		this.panePulsador = panePulsador;
	}

	public void setPaneVelTel(JEditorPane paneVelTel) {
		this.paneVelTel = paneVelTel;
	}

	public void setPaneInterfaz0(JEditorPane paneInterfaz0) {
		this.paneInterfaz0 = paneInterfaz0;
	}

	public void setPaneInterfaz1(JEditorPane paneInterfaz1) {
		this.paneInterfaz1 = paneInterfaz1;
	}

	public JTextField getTextFieldVelTel() {
		return textFieldVelTel;
	}

	public void setTextFieldVelTel(JTextField textFieldVelTel) {
		this.textFieldVelTel = textFieldVelTel;
	}
	
	
	public JEditorPane getPaneHabNS() {
		return paneHabNS;
	}
	public JEditorPane getPaneHabEO() {
		return paneHabEO;
	}

	public void setPaneHabNS(JEditorPane paneHabNS) {
		this.paneHabNS = paneHabNS;
	}

	public void setPaneHabEO(JEditorPane paneHabEO) {
		this.paneHabEO = paneHabEO;
	}
	
	
	public JButton getBtnConnect() {
		return btnConnect;
	}


	public Scoba getScoba() {
		return scoba;
	}


	public Boolean getAutoMode() {
		return autoMode;
	}


	public void setAutoMode(Boolean autoMode) {
		this.autoMode = autoMode;
	}
	
	private void activarAutoCupula()
	{
		this.setAutoMode(true);
		this.autoCupula = new Automatico(this, Movimiento.CUPULA);
		this.autoCupula.start();
		
	}
	
	private void activarAutoTelescopio()
	{
		this.setAutoMode(true);
		this.autoEncoder = new Automatico(this, Movimiento.ENCODER);
		this.autoEncoder.start();
		
	}
	
	private void activarAutoPlataforma()
	{
		this.setAutoMode(true);
		this.autoPlataf = new Automatico(this, Movimiento.PLATAFORMA);
		this.autoPlataf.start();
		
	}
	
	public JCheckBox getChckbxAutoMode() {
		return chckbxAutoMode;
	}
	
	public void actualizarValorEncoder(EncoderNombre nombre)
	{
		if(nombre.equals(EncoderNombre.ALFA))
		{
			Integer signoAlfa = this.getEncoderAlfa().getSigno();  //this.getTextAlfaSign().getText().isEmpty() ? 1 : -1;
			Integer segAlfa = this.getEncoderAlfa().getSegundos(); //Integer.parseInt(this.getTextAlfaSeg().getText());
			Integer minAlfa = this.getEncoderAlfa().getMinutos();  //Integer.parseInt(this.getTextAlfaMin().getText());
			Integer gradAlfa = Math.abs(this.getEncoderAlfa().getGrados());  //Integer.parseInt(this.getTextAlfaGrad().getText());
			this.getEncoderAlfa().calcularAnguloEnSegundos(gradAlfa, minAlfa, segAlfa, signoAlfa);
			//encoderAlfa.calcularGradMinSeg();
			System.out.println("Actualizando valor encoder alfa...");
			System.out.println(encoderAlfa.getAngulo());
			System.out.println(encoderAlfa.getGrados() + " " + encoderAlfa.getMinutos() + " " + encoderAlfa.getSegundos());
		}
		if(nombre.equals(EncoderNombre.DELTA))
		{
			Integer signoDelta = this.getEncoderDelta().getSigno();  // this.getTextDeltaSign().getText().isEmpty() ? 1 : -1;
			Integer segDelta = this.getEncoderDelta().getSegundos(); //Integer.parseInt(this.getTextDeltaSeg().getText());
			Integer minDelta = this.getEncoderDelta().getMinutos();  //Integer.parseInt(this.getTextDeltaMin().getText());
			Integer gradDelta = Math.abs(this.getEncoderDelta().getGrados());  //Integer.parseInt(this.getTextDeltaGrad().getText());
			this.getEncoderDelta().calcularAnguloEnSegundos(gradDelta, minDelta, segDelta, signoDelta);
			//encoderDelta.calcularGradMinSeg();
			System.out.println("Actualizando valor encoder delta...");
			System.out.println(encoderDelta.getAngulo());
			System.out.println(encoderDelta.getGrados() + " " + encoderDelta.getMinutos() + " " + encoderDelta.getSegundos());
		}
		
		else
		{
			
		}
		
		
	}


	@Override
	public void update(Observable objectObs, Object argument) {
		switch((Notificacion)argument)
		{
		case SIMU_ENCODER_ALFA:
			Integer gradosAlfa  = this.getEncoderAlfa().getGrados();
			this.getTextAlfaSeg().setText(String.format("%02d", this.getEncoderAlfa().getSegundos()));
			this.getTextAlfaMin().setText(String.format("%02d", this.getEncoderAlfa().getMinutos()));
			this.getTextAlfaGrad().setText(String.format("%03d", Math.abs( gradosAlfa)));
			break;
			
		case SIMU_ENCODER_DELTA:
			Integer gradosDelta  = this.getEncoderDelta().getGrados();
			this.getTextDeltaSeg().setText(String.format("%02d", this.getEncoderDelta().getSegundos()));
			this.getTextDeltaMin().setText(String.format("%02d", this.getEncoderDelta().getMinutos()));
			this.getTextDeltaGrad().setText(String.format("%03d", Math.abs(gradosDelta)));
			this.getTextDeltaSign().setText( (this.getEncoderDelta().getSigno().equals(-1)) ? "-" : " ");
			break;
			
		case SIMU_ENCODER_DELTA_SEGUNDOS:
			//System.out.println("notificando segundos delta");
			this.getTextDeltaSeg().setText(String.format("%02d", this.getEncoderDelta().getSegundos()));
			break;
		case SIMU_ENCODER_DELTA_MINUTOS:
			this.getTextDeltaMin().setText(String.format("%02d", this.getEncoderDelta().getMinutos()));
			break;
		case SIMU_ENCODER_DELTA_GRADOS:
			Integer gradosDelta_  = this.getEncoderDelta().getGrados();
			//System.out.println("notificando grados delta: " + this.getEncoderDelta().getGrados());
			this.getTextDeltaGrad().setText(String.format("%03d", Math.abs(gradosDelta_)));
			break;
		case SIMU_ENCODER_DELTA_SIGNO:
			this.getTextDeltaSign().setText( (this.getEncoderDelta().getSigno().equals(-1)) ? "-" : " ");

			break;
			
		case SIMU_ENCODER_ALFA_SEGUNDOS:
			//System.out.println("notificando segundos delta");
			this.getTextAlfaSeg().setText(String.format("%02d", this.getEncoderAlfa().getSegundos()));
			break;
		case SIMU_ENCODER_ALFA_MINUTOS:
			this.getTextAlfaMin().setText(String.format("%02d", this.getEncoderAlfa().getMinutos()));
			break;
		case SIMU_ENCODER_ALFA_GRADOS:
			Integer gradosAlfa_  = this.getEncoderAlfa().getGrados();
			//System.out.println("notificando grados delta: " + this.getEncoderAlfa().getGrados());
			this.getTextAlfaGrad().setText(String.format("%03d", Math.abs(gradosAlfa_)));
			break;
		case SIMU_ENCODER_ALFA_SIGNO:
			this.getTextAlfaSign().setText( (this.getEncoderAlfa().getSigno().equals(-1)) ? "-" : " ");

			break;	
		
		default:
			break;
				
		}
		
	}
}
